#!/bin/bash
#Author:liuml
#Blog:https://jiqinga.github.io
#Time:2020-11-02 10:41:00
#Name:/tmp/login.sh
#!/bin/bash
#########################################################################

#
# Logo
#
lolcat=/usr/local/bin/lolcat
logo='
                       -`
                      .o+`
                     `ooo/
                    `+oooo:
                   `+oooooo:
                   -+oooooo+:
                 `/:-:++oooo+:
                `/++++/+++++++:
               `/++++++++++++++:
              `/+++ooooooooooooo/`
             .ooosssso++osssssso+`
            .oossssso-````/ossssss+`
           -osssssso.      :ssssssso.
          :osssssss/        osssso+++.
         /ossssssss/        +ssssooo/-
       `/ossssso+/:-        -:/+osssso+-
      `+sso+:-`                 `.-/+oso:
     `++:.                           `-/+/
     .`                                 `/"
'

#
# Memory
#
# MemUsed = Memtotal + Shmem - MemFree - Buffers - Cached - SReclaimable
# Source: https://github.com/KittyKatt/screenFetch/issues/386#issuecomment-249312716

mem_info=/proc/meminfo
mem_total=$(awk '$1=="MemTotal:" {print $2}'  ${mem_info})
mem_used=$((${mem_total} + $(awk '$1=="Shmem:" {print $2}'  ${mem_info})))
mem_used=$((${mem_used} - $(awk '$1=="MemFree:" {print $2}'  ${mem_info})))
mem_used=$((${mem_used} - $(awk '$1=="Buffers:" {print $2}' ${mem_info})))
mem_used=$((${mem_used} - $(awk '$1=="Cached:" {print $2}' ${mem_info})))
mem_used=$((${mem_used} - $(awk '$1=="SReclaimable:" {print $2}'  ${mem_info})))

mem_total=$((mem_total / 1024))
mem_used=$((mem_used / 1024))
mem_usage=$((100 * ${mem_used} / ${mem_total}))

#
# Load average
#

load_average=$(awk '{print $1" "$2" "$3}' /proc/loadavg)

#
# Time
#

time_cur=$(date "+%F %X")

#
# Users
#

user_num=$(who -u | wc -l)

#echo -e "\033[0;36;40m$logo\033[0m"
echo  "$logo" |$lolcat  
echo -e "System time: \t$time_cur" |$lolcat 
echo -e "Memory used: \t${mem_used}MiB / ${mem_total}MiB ($mem_usage%)" |$lolcat 
echo -e "Load average:\t$load_average" |$lolcat 
echo -e "Users online:\t$user_num\n" |$lolcat 
